using System;
using System.Collections;
using UnityEngine;

[Serializable]
public class DemoSimple : MonoBehaviour
{
	public GameObject Exploder;

	private GameObject[] DestroyableObjects;

	public void Start()
	{
		DestroyableObjects = GameObject.FindGameObjectsWithTag("Exploder");
	}

	public void ChangeExploderParams()
	{
		Hashtable hashtable = new Hashtable();
		hashtable["DontUseTag"] = true;
		hashtable["Radius"] = 15f;
		hashtable["ForceVector"] = Vector3.one;
		hashtable["Force"] = 10f;
		hashtable["FrameBudget"] = 10;
		hashtable["TargetFragments"] = 200;
		hashtable["DeactivateOptions"] = 1;
		hashtable["DeactivateTimeout"] = 4f;
		hashtable["MeshColliders"] = false;
		hashtable["ExplodeSelf"] = false;
		hashtable["HideSelf"] = false;
		hashtable["DestroyOriginalObject"] = true;
		hashtable["ExplodeFragments"] = false;
		Exploder.SendMessage("SetFromJavaScript", hashtable);
	}

	public void OnGUI()
	{
		if (GUI.Button(new Rect(10f, 10f, 100f, 30f), "Explode!") && (bool)Exploder)
		{
			Exploder.SendMessage("Explode");
		}
		if (!GUI.Button(new Rect(130f, 10f, 100f, 30f), "Reset"))
		{
			return;
		}
		Activate(Exploder, status: true);
		int i = 0;
		GameObject[] destroyableObjects = DestroyableObjects;
		for (int length = destroyableObjects.Length; i < length; i++)
		{
			if ((bool)destroyableObjects[i])
			{
				Activate(destroyableObjects[i].gameObject, status: true);
			}
		}
	}

	public void Activate(GameObject obj, bool status)
	{
		if ((bool)obj)
		{
			int childCount = obj.transform.childCount;
			for (int i = 0; i < childCount; i++)
			{
				Activate(obj.transform.GetChild(i).gameObject, status);
			}
			obj.SetActive(status);
		}
	}

	public void Main()
	{
	}
}
